# -*- coding: utf-8 -*-
# @Time : 2023/10/23 20:50
# @Author : ZH
# @File : 17.py
# @Software: PyCharm
from typing import List


class Solution:
    def __init__(self):
        self.num_en = {
            '2': ['a', 'b', 'c'],
            '3': ['d', 'e', 'f'],
            '4': ['g', 'h', 'i'],
            '5': ['j', 'k', 'l'],
            '6': ['m', 'n', 'o'],
            '7': ['p', 'q', 'r', 's'],
            '8': ['t', 'u', 'v'],
            '9': ['w', 'x', 'y', 'z']
        }

    def letterCombinations(self, digits: str) -> List[str]:
        if len(digits) == 1: return self.num_en[digits]
        if not digits: return []
        all_num = []
        for i in digits:
            all_num.append(i)
        end_list = []
        e_list = []

        def ccc(index):
            if index == len(digits):
                end_list.append(''.join(e_list))
            else:
                nn = self.num_en[digits[index]]
                for i in nn:
                    e_list.append(i)
                    ccc(index=index+1)
                    e_list.pop()

        ccc(0)
        return end_list

if __name__ == '__main__':
    so = Solution()
    digits = "23"
    l = so.letterCombinations(digits=digits)
    print(l)



